<?php

class admin_template_content_article_edit extends admin_theme
{

    protected function center()
    {
        $article = $this->get('article');
        $categories = $this->get('categories');
        
        $category_html = '<select name="category_id">';
        $category_html .= '<option value="">不属于任何分类</option>';
        foreach ($categories as $category)
        {
            $category_html .= '<option value="' . $category->id . '"';
            if ($category->children > 0) $category_html .= ' disabled';
            $category_html .= '>';
            if ($category->level) $category_html .= str_repeat('&nbsp; ', $category->level);
            $category_html .= $category->name . '</option>';
        }
        $category_html .= '</select>';

        $ui_editor = bone::get_admin_ui('editor');
		$ui_editor->set_action('./?action=content.article.edit_save');
		$ui_editor->set_fields(
            array(
            	'type'=>'text', 
            	'name'=>'title', 
            	'label'=>'标题', 
            	'value'=>$article->title, 
            	'width'=>'500px', 
            	'validate'=>array(
            		'required'=>true
                )
            ), 
            array(
            	'type'=>'select', 
            	'label'=>'所属分类', 
            	'html'=>$category_html
            ), 
            array(
            	'type'=>'textarea', 
            	'name'=>'summary', 
            	'label'=>'摘要', 
            	'value'=>$article->summary, 
            	'width'=>'500px', 
            	'height'=>'45px'
            ), 
            array(
            	'type'=>'richtext', 
            	'name'=>'body', 
            	'label'=>'内容', 
            	'value'=>$article->body, 
            	'width'=>'600px', 
            	'height'=>'360px'
            ), 
            array(
            	'type'=>'text', 
            	'name'=>'hits', 
            	'label'=>'点击量', 
            	'value'=>$article->hits, 
            	'validate'=>array(
            		'digits'=>true
                )
            ), 
            array(
            	'type'=>'textarea', 
            	'name'=>'meta_keywords', 
            	'label'=>'<small>Mata Keywords</small>', 
            	'value'=>$article->meta_keywords, 
            	'width'=>'500px', 'height'=>'30px'
            ), 
            array(
            	'type'=>'textarea', 
            	'name'=>'meta_description', 
            	'label'=>'<small>Meta Description</small>', 
            	'value'=>$article->meta_description, 
            	'width'=>'500px', 
            	'height'=>'30px'
            )
        );
		$ui_editor->add_hidden('id', $article->id);
		$ui_editor->add_hidden('return', $this->get('return'));
		
		$ui_editor->set_reset('重设');
		$ui_editor->set_back('返回', base64_decode($this->get('return')));
		$ui_editor->display();
        
    }
}
?>